<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/30
 * Time: 16:14
 */

namespace App\LogicService;

use App\LogicService\Contracts\OphthalmologyRetinopathyLogicContract;
use App\Models\OphthalmologyRetinopathy;


class OphthalmologyRetinopathyLogic extends BaseLogic implements OphthalmologyRetinopathyLogicContract
{
    public function update($record_id, $value)
    {
        $ophthalmologyRetinopathy = OphthalmologyRetinopathy::firstOrCreate(['record_id' => $record_id]);
        $ophthalmologyRetinopathy->left = $value['left'];
        $ophthalmologyRetinopathy->right = $value['right'];
        $ophthalmologyRetinopathy->remark = $value['remark'];
        $ophthalmologyRetinopathy->save();

        return $ophthalmologyRetinopathy;
    }

    public function show($record_id)
    {
        $ophthalmologyRetinopathy = OphthalmologyRetinopathy::where('record_id', $record_id)
            ->first();

        if ($ophthalmologyRetinopathy) {
            $ophthalmologyRetinopathy = $ophthalmologyRetinopathy->toArray();
        } else {
            $ophthalmologyRetinopathy = [];
        }
        return $ophthalmologyRetinopathy;
    }
}